Skip to content

[Dropzone] Enable multiple file uploads - #512

Closed
daFish wants to merge 5 commits into
symfony:2.xfrom
daFish:feat/dropzone-support-multiple-files
Closed

[Dropzone] Enable multiple file uploads#512
daFish wants to merge 5 commits into
symfony:2.xfrom
daFish:feat/dropzone-support-multiple-files

Conversation

@daFish

@daFish daFish commented Oct 24, 2022

Copy link
Copy Markdown
Contributor
Q A
Bug fix? no
New feature? yes
Tickets Fix #7
License MIT

This change adds the posibility to upload multiple files using the Dropzone component. This is based on the work by @yassinehamouten.

  • Tests
  • Make it configurable using the FormType

@daFish
daFish force-pushed the feat/dropzone-support-multiple-files branch from e8a8a1e to 7105e52 Compare October 24, 2022 13:31
@daFish
daFish marked this pull request as ready for review October 24, 2022 13:36
@daFish
daFish marked this pull request as draft October 24, 2022 20:03
@daFish
daFish force-pushed the feat/dropzone-support-multiple-files branch from 7105e52 to 05ffafc Compare October 25, 2022 06:56
@daFish
daFish marked this pull request as ready for review October 25, 2022 06:57
@daFish

daFish commented Oct 25, 2022

Copy link
Copy Markdown
Contributor Author

@tgalopin & @weaverryan Would you mind to review this PR? 😄

@weaverryan weaverryan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I have some questions - either we're not (yet) quite supporting the "preview" for multiple files, or I'm missing it!

Cheers :)

{%- set dataController = (attr['data-controller']|default('') ~ ' symfony--ux-dropzone--dropzone')|trim -%}
{%- set attr = attr|merge({ 'data-controller': '', class: (attr.class|default('') ~ ' dropzone-input')|trim}) -%}


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, but we can revert this change

}

this._dispatchEvent('dropzone:change', file);
this._dispatchEvent('dropzone:change', event.target.files);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not this in the CHANGELOG - that's a minor BC break.

this.previewImageTarget.style.display = 'none';
this.previewImageTarget.style.backgroundImage = 'none';
this.previewFilenameTarget.textContent = '';
document.querySelectorAll('.dropzone-preview-image-container').forEach((e) => e.remove());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I'm missing it, where/what is creating this .dropzone-preview-image-container element?


// Show the filename in preview
this.previewFilenameTarget.textContent = file.name;
this.previewTarget.style.display = 'flex';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried the code yet, but how does this work with multiple files? It looks like if I attach multiple files, only the last one's filename would show up (it would override the earlier ones). Or very possibly I am missing a detail :)

@daFish

daFish commented Nov 2, 2022

Copy link
Copy Markdown
Contributor Author

After a small conversation with @weaverryan on Slack I plan to add the following options to this component:

  • ability to specify the number of files
  • enable adding additional files after files were already dropped

@daFish
daFish marked this pull request as draft December 8, 2022 18:19
@daFish daFish changed the title feat(dropzone): enable multiple file uploads [Dropzone] Enable multiple file uploads Dec 8, 2022
@daFish
daFish force-pushed the feat/dropzone-support-multiple-files branch from 806cc8a to 3e47174 Compare January 26, 2023 10:44

@weaverryan weaverryan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!

I played with this locally, but it doesn't look like multiple previews show up - just the one. Is that my mistake? Or do we still need a good deal more work - like to have potentially multiple "preview" areas instead of just one?

Thanks!

Comment thread src/Dropzone/assets/src/controller.ts Outdated
numberOfFiles: Number
}

readonly numberOfFilesValue: number;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like this is used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already removed.

{%- set dataController = (attr['data-controller']|default('') ~ ' symfony--ux-dropzone--dropzone')|trim -%}
{%- set attr = attr|merge({ 'data-controller': '', class: (attr.class|default('') ~ ' dropzone-input')|trim}) -%}


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/Dropzone/src/Form/DropzoneType.php Outdated
'attr' => [
'placeholder' => 'Drag and drop or browse',
],
'multiple' => false,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that needed? It's already the default of the parent type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has been removed.

@kristjan-kure

Copy link
Copy Markdown

Hi! We need multiple file upload. Who can help with this? I understand daFish has been developing it, but we need it live? Who on the Symfony development team can help us to work with this?

@daFish

daFish commented Apr 11, 2023

Copy link
Copy Markdown
Contributor Author

After some thoughts I'm not going to finish this. It is based upon the work of @yassinehamouten and I'd rather propose to go with uppy.io.

@daFish daFish closed this Apr 11, 2023
@daFish
daFish deleted the feat/dropzone-support-multiple-files branch April 11, 2023 15:49
@simonsolutions

Copy link
Copy Markdown
Contributor

sorry to pick up on the old PR. But the above mentioned missing preview on more than one file seems still not to be working. I tried the current version of UX Dropzone, the multiple in the form element works. It accepts multiple files and posts them along with the form. But the preview of more than one file and the capability of adding more files seems also be missing.

Is there any trick i am missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dropzone: handle multiple files

4 participants